#include "../logs/qywlog.h"

// 日志器使用样例
  void test_log(const std::string &name)
  {  
    // 默认root日志器输出
    FATAL("%s", "开始测试");
    // 自定义日志器输出
    qywlog::Logger::ptr logger = qywlog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");
    // 默认root日志器输出
    FATAL("%s", "测试完毕");   
  }

int main()
{
  // 日志器模块管理器测试 + 全局单例模式下日志器的建造者
  std::unique_ptr<qywlog::LoggerBuilder> builder(new qywlog::GlobalLoggerBuilder());
  builder->buildLoggerName("async_logger");
  builder->buildLoggerLevel(qywlog::LogLevel::value::DEBUG);
  builder->buildFormatter("[%c][%f:%l][%p]%m%n");
  builder->buildLoggerType(qywlog::LoggerType::LOGGER_ASYNC);
  builder->buildSink<qywlog::StdoutSink>();
  builder->buildSink<qywlog::FileSink>("./logfile/async.log");
  builder->buildSink<qywlog::RollBySizeSink>("./logfile/roll-async-by-size", 1024*1024);
  builder->build();
  test_log("async_logger");

  return 0;
}
